home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / JAVA / IO / PushbackInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  863 b   |  51 lines

  1. package java.io;
  2.  
  3. public class PushbackInputStream extends FilterInputStream {
  4.    protected int pushBack = -1;
  5.  
  6.    public PushbackInputStream(InputStream var1) {
  7.       super(var1);
  8.    }
  9.  
  10.    public int read() throws IOException {
  11.       int var1 = this.pushBack;
  12.       if (var1 != -1) {
  13.          this.pushBack = -1;
  14.       } else {
  15.          var1 = super.in.read();
  16.       }
  17.  
  18.       return var1;
  19.    }
  20.  
  21.    public int read(byte[] var1, int var2, int var3) throws IOException {
  22.       if (this.pushBack != -1) {
  23.          if (var3 == 0) {
  24.             return 0;
  25.          } else {
  26.             var1[var2] = (byte)this.pushBack;
  27.             this.pushBack = -1;
  28.             return 1;
  29.          }
  30.       } else {
  31.          return super.in.read(var1, var2, var3);
  32.       }
  33.    }
  34.  
  35.    public void unread(int var1) throws IOException {
  36.       if (this.pushBack != -1) {
  37.          throw new IOException("Attempt to unread more than one character!");
  38.       } else {
  39.          this.pushBack = var1;
  40.       }
  41.    }
  42.  
  43.    public int available() throws IOException {
  44.       return this.pushBack == -1 ? super.available() : super.available() + 1;
  45.    }
  46.  
  47.    public boolean markSupported() {
  48.       return false;
  49.    }
  50. }
  51.